<%--
    Document   : listarea
    Created on : Oct 25, 2011, 7:49:12 PM
    Author     : Venus
--%>

<%--
    Tham số hệ thống
areaname  order   status   action
arealist  enable  disable  search
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT,Models.ThamSoHT_Model"%>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'areaname', 'notice', 'rightmsg', 'order','status','arealist', 'enable', 'disable', 'all' "; // chuỗi chứa các mã tham số của trang này.
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.
            String all = mdsts[0].getTenTS();
            String arealist = mdsts[1].getTenTS();
            String areaname = mdsts[2].getTenTS();
            String disable = mdsts[3].getTenTS();
            String enable = mdsts[4].getTenTS();
            String notice = mdsts[5].getTenTS();
            String order = mdsts[6].getTenTS();
            String rightmsg = mdsts[7].getTenTS();
            String status = mdsts[8].getTenTS();

            String msgright = notice + "/" + rightmsg;

            Vector v = (Vector) request.getAttribute("DSKV");

            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 7 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 7;
            } else {
                numpage = vsize / 7 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String tenkvv = (String) request.getAttribute("tenkv");
            String statuss = (String) request.getAttribute("status");
%>


<div class="title">
    <%=arealist%>
    
</div>
<div class="content">
    <form name="dskhuvuc" action="">
        <table class="mytable" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th style="width: 10%;  "><%=order%></th>
                    <th style="width: 18%; ">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" onclick="SortSearchTenKV( this.className, this.name, this.lang)">
                            <div style="float:left"><%=areaname%></div>
                            <div id="sortkv1" style=" margin-right: 55px;" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 20%; margin-top: 2px;">
                        <a href="#" id="titledskv2" class="down"  name="1" lang="<%=msgright%>" onclick="SortSearchTTKV( this.className, this.name, this.lang)">
                            <div><%=status%></div>
                            <div >
                                <div id="sortkv2" class="down2"></div>
                                <div id="sortkv2" class="up2" style="display:none;"></div>
                            </div>
                        </a>
                    </th>
                </tr>
                <tr id="searchTenKV">
                    <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" lang="<%=msgright%>" alt="1" src="../images/search1.png" onclick="SearchKV(this.alt, this.lang)"></th>
                    <th><input type="textbox" style="width: 120px;" class="text" name="TENKV" alt="1" size="17" lang="<%=msgright%>" value="<%= tenkvv%>"></th>
                    <th>
                        <div>
                            <select  class="select" id="1" name="TINHTRANG" lang="<%=msgright%>" onchange="SearchKV(this.id, this.lang)">
                                <%
                                                if (statuss.equals("1")) {%>
                                <option value="1"><%=enable%></option>
                                <option value="0"><%=disable%></option>
                                <option value="all"><%=all%></option>
                                <%    } else if (statuss.equals("0")) {%>
                                <option value="0"><%=disable%></option>
                                <option value="1"><%=enable%></option>
                                <option value="all"><%=all%></option>
                                <%  } else {%>
                                <option value="all"><%= all%></option>
                                <option value="1"><%=enable%></option>
                                <option value="0"><%=disable%></option>
                                <%    }
                                %>

                            </select>
                        </div>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                            for (int i = (item - 1) * 7; i < (item - 1) * 7 + 7 && i < vsize; i++) {
                                Beans.KhuVuc kv = (Beans.KhuVuc) v.elementAt(i);
                %>
                <tr>
                    <td class="STT"><%= i + 1%></td>
                    <td class="TenKV"><a href="#" name="<%=kv.getMaKV()%>" lang="<%=msgright%>" onclick="ShowLangKV(this.name, this.lang)"><%= kv.getTenKV()%></a></td>
                    <td>
                        <select  class="<%= kv.getMaKV()%>" lang="<%=msgright%>" onchange="UpdateStatusKV(this.value, this.className, this.lang)">
                            <%
                                                                            if (kv.getTinhTrang() == 1) {%>
                            <option value="1"><%= enable%></option>
                            <option value="0"><%= disable%></option>
                            <%  } else {%>
                            <option value="0"><%= disable%></option>
                            <option value="1"><%= enable%></option>
                            <%  }
                            %>
                        </select>
                    </td>
                </tr>
                <%  }
                %>
            </tbody>
        </table>
        <div class="pagination" style=" margin-top: 20px;">
            <%
                        int trang = 1;
                        if (item > 1) {
                            trang = item - 1;
                        }
            %>
            <%
                                if (vsize > 7) {%>
            <a href="#" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SearchKV( this.name, this.lang)">«</a>
            <%
                                                for (int c = 1; c <= numpage; c++) {

                                                    if (c != item) {
            %> <a href="#"  name="<%= c%>" lang="<%=msgright%>" onclick="SearchKV(this.name, this.lang)" ><%= c%></a>
            <% } else {%><a class="current"> <%= c%></a> <% }

                                                }
            %>
            <%
                                                if (item + 1 <= numpage) {
                                                    trang = item + 1;
                                                } else {
                                                    trang = item;
                                                }
            %>
            <a href="#" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SearchKV( this.name, this.lang)">»</a>

            <%  }
            %>
        </div>
    </form>
</div>
